package demo05;

import java.util.function.Function;

/*
 *  类引用构造器
 */
public class Demo04MethodReference {
    public static void main(String[] args) {
        // 使用Lambda
        System.out.println(changePerson("土司鸡", name->new Person(name))); // Person [name=土司鸡]
        // 使用方法引用
        System.out.println(changePerson("粹花花", Person::new)); // Person [name=粹花花]
    }

    public static Person changePerson(String name, Function<String, Person> function) {
        return function.apply(name);
    }
}
